# -*- coding: UTF-8 -*-
import os.path
from kivy.utils import platform


def rgb(s):
    r = s[:2]
    g = s[2:4]
    b = s[4:]
    return [int(r, 16) / 255.00, int(g, 16) / 255.0, int(b, 16) / 255.0, 1]

# for main
PATH = os.path.abspath('.')
LOCALE_PATH = os.path.join(PATH, 'locales')

CONFIG_FILE = PATH + '/data/config.ini'
CONFIG_TEMPLATE_FILE = PATH + '/data/config.ini.template'
DEFAULT_NAMES = PATH + '/data/default_names.txt'
ICON = PATH + '/assets/icon-small.png'
KEYS_BACK = [1001]  # Android's back
KEYS_HOME = [1002]  # Android's home

if platform != 'android':
    KEYS_BACK.append(27)  # Escape works as Back
    KEYS_HOME.append(283)  # F2 works as Home

LOCALE = 'en_US'
PICKLED_GAMESTATE = PATH + '/data/pickled_gamestate.pkl'
STATISTICS_FOLDER = PATH + '/statistics'

# for skip_words
INF = 10000

# for game_config.py
MIN_PLAYERS = 2
DEFAULT_PLAYERS = 6
MAX_PLAYERS = 16
STEP_PLAYERS = 1

MIN_ROUNDS = 0
DEFAULT_ROUNDS = 100
MAX_ROUNDS = 100
STEP_ROUNDS = 1

MIN_TIME = 5
DEFAULT_TIME = 20
MAX_TIME = 3600
STEP_TIME = 5

MIN_WORDS = 5
DEFAULT_WORDS = 10
MAX_WORDS = 60
STEP_WORDS = 1

# for statistics
STATISTIC_COUNT = 20
EXPORT_PROTOCOL_VERSION = '1.0'
JSON_TIMEOUT = 5

HOST = "@AE_SERVER@"

# ...
STEPS = {'time': STEP_TIME, 'words': STEP_WORDS, 'players': STEP_PLAYERS,
         'rounds': STEP_ROUNDS}
BOUNDS = {'time': (MIN_TIME, MAX_TIME),
          'words': (MIN_WORDS, MAX_WORDS),
          'players': (MIN_PLAYERS, MAX_PLAYERS),
          'rounds': (MIN_ROUNDS, MAX_ROUNDS)}
DEFAULTS = {'time': DEFAULT_TIME, 'words': DEFAULT_WORDS,
            'players': DEFAULT_PLAYERS, 'rounds': DEFAULT_ROUNDS}
LABELS = {'time': 'Round duration',
          'words': 'Words per player',
          'players': 'Players count',
          'rounds': 'Round count'}

# for sounds
FAILED_SOUND = PATH + '/sounds/long_sound_2.wav'
GUESSED_SOUND = PATH + '/sounds/ok_sound_3.wav'
LAST_SECONDS_FINISHED_SOUND = PATH + '/sounds/end_sound_1.wav'
PUT_BACK_SOUND = PATH + '/sounds/fail_sound_2.wav'
TIME_UP_SOUND = PATH + '/sounds/long_sound.wav'

MIN_PIN_LENGTH = 4
MAX_PIN_LENGTH = 6
COLOR = {'blue': rgb('33B5E5'), 'green': rgb('99CC00'), 'red': rgb('FF4444'),
         'orange': rgb('FFBB33'), 'purple': rgb('AA66CC'),
         'DEFAULT_': rgb('FFFFFF'), 'deem_green': rgb('669900'),
         'default': rgb('FFFFFF'), 'deem_green': rgb('669900'),
         'grey': (0.7, 0.7, 0.7, 1)}

from kivy.uix.popup import Popup
from ui.hat_widget import HatPopup
POPUP_TYPE = (Popup, HatPopup)
